package com.ctgu.service.serviceimpl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ctgu.entity.Information;
import com.ctgu.mapper.InformationMapper;
import com.ctgu.service.InformationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author nepture
 */
@Service
public class InformationImpl extends ServiceImpl<InformationMapper, Information> implements InformationService {

    @Resource
    InformationMapper mapper;

    @Override
    public Map<String, Object> selectAllUser(Information information) {
        LambdaQueryWrapper<Information> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(StringUtils.isNotBlank(information.getName()), Information::getName, information)
                .eq(StringUtils.isNotBlank(information.getTelephone()), Information::getTelephone, information)
                .eq(StringUtils.isNotBlank(information.getSignature()), Information::getSignature, information);
        return getMap(wrapper);
    }

    @Override
    public boolean updateOrAddInformation(Information information) {
        saveOrUpdate(information);
        return false;
    }
}
